package enum

import "errors"

// NodeType 节点类型
type NodeType string

func (n NodeType) String() string {
	return string(n)
}

const (
	// StartEvent 开始事件
	StartEvent NodeType = "startEvent"
	// EndEvent 结束事件
	EndEvent NodeType = "endEvent"
	// TerminateEvent 终止事件
	TerminateEvent NodeType = "terminateEvent"
	// UserTask 人工任务
	UserTask NodeType = "userTask"
	// ExclusiveGateway 排他网关
	ExclusiveGateway NodeType = "exclusiveGateway"
	// ParallelGateway 并行网关
	ParallelGateway NodeType = "parallelGateway"
	// timerEvent
	TimeEvent NodeType = "timerEvent"
	// timeNodeEvent
	TimeNodeEvent NodeType = "timeNodeEvent"
	// MessageEvent
	MessageEvent NodeType = "messageEvent"
	// Unknown 未知类型
	Unknown NodeType = "Unknown"
)

func GetString(node NodeType)(string){
	switch node {
	case EndEvent:
		return "endEvent"
	case StartEvent:
		return "startEvent"
	case ExclusiveGateway:
		return "exclusiveGateway"
	case ParallelGateway:
		return "parallelGateway"
	case TerminateEvent:
		return "terminateEvent"
	case UserTask:
		return "userTask"
	case TimeEvent:
		return "timerEvent"
	case TimeNodeEvent:
		return "timeNodeEvent"
	case MessageEvent:
		return "messageEvent"
	case Unknown:
		return "Unknown"
	}
	return "Unknown"
}

// GetNodeTypeByName 转换节点类型
func GetNodeTypeByName(s string) (NodeType, error) {
	switch s {
	case "startEvent":
		return StartEvent, nil
	case "endEvent":
		return EndEvent, nil
	case "terminateEvent":
		return TerminateEvent, nil
	case "userTask":
		return UserTask, nil
	case "exclusiveGateway":
		return ExclusiveGateway, nil
	case "parallelGateway":
		return ParallelGateway, nil
	case "timerEvent":
		return TimeEvent,nil
	case "timeNodeEvent":
		return TimeNodeEvent,nil
	case "messageEvent":
		return MessageEvent,nil

	}
	return Unknown, errors.New(s + "不支持的类型")
}

// 设置流程状态
type ProcessStatus string
const (
	PROCESSRUNNING ProcessStatus = "Running"
	FINISH         ProcessStatus = "Finished"
	UNKNOWN        ProcessStatus = "Unknown"
)
func (n ProcessStatus) String() string {
	return string(n)
}

func GetProcessStatus(pstatus string) (ProcessStatus, error)  {
	switch pstatus {
	case "Running":
		return PROCESSRUNNING,nil
	case "Finished":
		return FINISH,nil
	}
	return UNKNOWN,nil
}

// 设置流程节点状态
type ProcessNodeStatus string
const (
	NodeRunning       ProcessNodeStatus = "Running"
	NodeFinished      ProcessNodeStatus = "Finished"
	NODESTATUSUNKNOWN ProcessNodeStatus = "Unknown"
)
func (n ProcessNodeStatus) String() string {
	return string(n)
}

func GetProcessNodeStatus(pstatus string) (ProcessNodeStatus, error)  {
	switch pstatus {
	case "Running":
		return NodeRunning,nil
	case "Finished":
		return NodeFinished,nil
	}
	return NODESTATUSUNKNOWN,nil
}

// 设置流程状态
type EventStatus string
const (
	EVENTINT     EventStatus = "Init"
	EVENTRUNNING EventStatus = "Running"
	EVENTFINISH  EventStatus = "Finished"
	EVENTUNKNOWN EventStatus = "Unknown"
)
func (n EventStatus) String() string {
	return string(n)
}

func GetEventStatus(pstatus string) (EventStatus, error)  {
	switch pstatus {
	case "Running":
		return EVENTRUNNING,nil
	case "Finished":
		return EVENTFINISH,nil
	case "Init":
		return EVENTINT,nil
	}
	return EVENTUNKNOWN,nil
}


// 设置流程LEVEL
type EventLevel string
const (
	EVENTLEVEL_PROCESS  EventLevel = "Process"
	EVENTLEVEL_INSTANCE EventLevel = "Instance"
)
func (n EventLevel) String() string {
	return string(n)
}

// 设置事件类型
type EventType string
const (
	EVENTTYPE_STARTTIMEEVENT EventType = "StartTimeEvent"
	EVENTTYPE_STARTMESSAGEEVENT EventType = "StartMessageEvent"
)
func (n EventType) String() string {
	return string(n)
}


type TopicType string

const(
	TOPICTYPE_STARTEVENT TopicType="StartTopicEvent"
	TOPICTYPE_UNKNOWN    TopicType="Unknown"
)
func (n TopicType) String() string {
	return string(n)
}

func GetTopicType(pstatus string) (TopicType, error)  {
	switch pstatus {
	case "StartTopicEvent":
		return TOPICTYPE_STARTEVENT,nil
	}
	return TOPICTYPE_UNKNOWN,nil
}

type BtnClientType string

const(
	BTN_CLIENT_TYPE_AGREE			BtnClientType= "Agree"
	BTN_CLIENT_TYPE_REJECT			BtnClientType= "Reject"
)

func (n BtnClientType)String() string {
	return string(n)
}

